<? 
	include('base.php');
	User::protect();
	include_class('releases');
	$section = 'releases';
	
	if ($_POST['submit']) { 
		// add news entry
		$r = Release::add($_POST);
		if (!db::isError($r)) {
			header('Location: release_edit.php?id=' . $r->getID());
		}
	}
	$editors = array('notes','press_notes');
	$calendar = true;	
	$page_title = 'Add Release';
	include('layout/header.php');
?>

<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>
	<a href="releases.php">Releases &#62;</a>
</div>

<? 

if (db::isError($r)) {
	$r->outputList();
}

if (User::isAdmin()) { ?>

	<h1>new entry:</h1>
	<div class="inset">
	<form id="add_new_entry" action="<?=$PHP_SELF?>" method="post">
	<table border="0" class="edit-form" cellspacing="0" cellpadding="0">
	<tr>
		<td width="33%"><strong>Title</strong><br/><input type="text" name="title" class="text" value="<?=$_POST['title']?>"></td>
		<td width="34%"><strong>Sub Title (if applies)</strong><br/><input type="text" name="sub_title" class="text" value="<?=$_POST['sub_title']?>"></td>
		<td width="33%"><strong>Release Date (<a style="vertical-align: middle" href="javascript:void(0)" onclick="popUpCalendar(this, document.getElementById('date'), '<?=DATE_JS_CALENDAR?>')">Calendar</a>)</strong><br/><input type="text" name="date" id="date" class="text" value="<?=$_POST['date']?>"></td>
	</tr>
	</table>
	<div class="edit-form">
		<strong>Notes</strong><br/>
		<textarea name="notes" class="full" id="notes"><?=$_POST['notes']?></textarea>
	</div>
	<div class="edit-form">
		<strong>Press Notes</strong><br/>
		<textarea name="press_notes" class="full" id="press_notes"><?=$_POST['press_notes']?></textarea>
	</div>
	<div class="edit-form">
		<input type="submit" value="Add Release" class="button" name="submit">
		<input type="submit" value="Exit Without Adding" class="button" name="preview" onclick="location.href='releases.php'; return false">
	</div>
	
	</div>

<? } else {
	Error::outputDialog('Return to Releases','releases.php','You do not have access to add releases.');
}

include('layout/footer.php'); ?>
